import {info} from '../../assets/js/api'

const login = {
  state: {
    token: '',// token
    info: [],//用户信息
    router: []
  },
  mutations: {
    ['SET_TOKEN'](state, token) {
      state.token = token;
      sessionStorage.token = token;
    },
    ['DEL_TOKEN'](state) {
      state.token = '';
      sessionStorage.removeItem('token');
    },
    ['ADD_ROUTER'](state, list) {
      state.router = list;
    }
  },
  actions: {
    ['GET_INFO'](context) {
      return info({
        token: context.state.token,
      });
    }
  },
};

export default login;
